package com.passion.fs.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 类描述：本地文件系统配置
 *
 * @author ZhuYin
 * @since 2025年01月06日
 */
@Data
@Component
@ConditionalOnProperty(prefix = "archives.fs", name = "type", havingValue = "local")
@ConfigurationProperties(prefix = "archives.fs.local")
public class LocalFsConfig {

    /** 本地文件系统上传的根路径 */
    public static String directory;

    /** 上传之后的文件访问端点 */
    public static String endpoint;

    /** 上传的文件是否加密，默认:false-不加密 */
    public static boolean encrypt;

    /** 文件系统中是否允许重复文件存在 */
    public static boolean allowFileDuplicate;


    @Value("${archives.fs.local.directory}")
    public void setDirectory(String directory) {
        LocalFsConfig.directory = directory;
    }

    @Value("${archives.fs.local.endpoint}")
    public void setEndpoint(String endpoint) {
        LocalFsConfig.endpoint = endpoint;
    }

    @Value("${archives.fs.local.encrypt:false}")
    public void setEncrypt(boolean encrypt) {
        LocalFsConfig.encrypt = encrypt;
    }

    @Value("${archives.fs.local.allowFileDuplicate:true}")
    public void setAllowFileDuplicate(boolean allowFileDuplicate) {
        LocalFsConfig.allowFileDuplicate = allowFileDuplicate;
    }

}
